package com.m3839.sdk.common.base;

import android.content.Context;
import android.webkit.JavascriptInterface;
import android.webkit.URLUtil;

import com.m3839.sdk.common.util.AppUtils;
import com.m3839.sdk.common.util.LogUtils;
import com.m3839.sdk.common.util.WebUtils;

/**
 * @author ChenBaoyang
 * @description: BaseJsInterface
 * @date 2021/11/15 15:40
 */
public abstract class BaseJsInterface {

    private static final String DOWNLOAD_URL = "https://m.3839.com/qd-pay.html";

    public static final String JS_INTERFACE_NAME = "HykbJsInterface";

    protected Context context;

    public BaseJsInterface(Context context) {
        this.context = context;
    }

    /**
     * h5调用跳转到浏览器下载快爆APP
     */
    @JavascriptInterface
    public void onJumpToDownloadApp() {
        LogUtils.flog("onJumpToDownloadApp");
        AppUtils.openUrl(context, DOWNLOAD_URL);
    }

    /**
     * h5调用跳转到浏览器服务和隐私条款
     */
    @JavascriptInterface
    public void onJumpToWeb(String url) {
        LogUtils.flog("onJumpToWeb = "+ url);
        AppUtils.openUrl(context, url);
    }
}
